Attribute VB_Name = "modConvertText"
Option Explicit
Function getLine() As String

    
    Selection.endKey Unit:=wdLine, Extend:=wdExtend
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    getLine = Selection.Text
End Function

Sub ksks()

    '//MsgBox Selection.Information(
    If Selection.Text = Chr(13) Then
    
        MsgBox "yeah"
    End If


End Sub

Sub moverightbyword()
    Dim blnWasThereMovement As Boolean
    blnWasThereMovement = False
    If Selection.Text = " " Then
        While Selection.Text = " "
            Selection.MoveRight Unit:=wdCharacter
        Wend
    Else
        If Selection.Text <> Chr(13) Then
            While Selection.Text <> " " & _
                Selection.Text <> Chr(13)
                Selection.MoveRight Unit:=wdCharacter
            Wend
            While Selection.Text = " "
                Selection.MoveRight Unit:=wdCharacter
            Wend
        End If
    End If

    

End Sub


Sub Main()
    With Selection
    '.HomeKey Unit:=wdStory
    Dim sChords() As String
    Dim getSomeChordText As String
    getSomeChordText = ""
    
    Call getChordText(getSomeChordText)
    sChords = Split(getSomeChordText, ",")

    
    Dim iChordsCharsFromStart() As Integer
    Dim iUbound As Integer
    iUbound = UBound(sChords)
    Debug.Print iUbound
    ReDim iChordCharsFromStart(0 To UBound(sChords))
    Dim iChord As Integer
    iChord = 0
    Dim lendchord As Long 'long -- end of the chords line
    .endKey Unit:=wdLine
    lendchord = .End
    .HomeKey Unit:=wdLine
    
    While (Not .End = lendchord - 1)
        moverightbyword
        If Not .End = lendchord - 1 Then
            Dim rng1 As Range
            Set rng1 = .Range
            .MoveDown
            .HomeKey Unit:=wdLine, Extend:=wdExtend
            iChordCharsFromStart(iChord) = Len(.Text)
            iChord = iChord + 1
            rng1.Select
        End If

    Wend
    .WholeStory
    .Font.Name = "Times New Roman"
    .HomeKey Unit:=wdStory
    .endKey Unit:=wdLine, Extend:=wdExtend
    .Delete
    .MoveRight Unit:=wdCharacter, Count:=iChordCharsFromStart(0) - 1
    Dim lTextFromRight As Long
    lTextFromRight = .Information(wdHorizontalPositionRelativeToPage)
    .HomeKey Unit:=wdLine
    .TypeParagraph
    .MoveUp
    .endKey Unit:=wdLine
    While .Information(wdHorizontalPositionRelativeToPage) < lTextFromRight
        .TypeText " "
    Wend
    .MoveLeft Unit:=wdCharacter, Count:=2
    .TypeText sChords(0)
    
    Dim ie As Integer
    For ie = 1 To UBound(sChords)
    .MoveDown
    .HomeKey Unit:=wdLine
    .MoveRight Unit:=wdCharacter, Count:=iChordCharsFromStart(ie) - 1
    lTextFromRight = .Information(wdHorizontalPositionRelativeToPage)
    .MoveUp
    While .Information(wdHorizontalPositionRelativeToPage) < lTextFromRight
        .TypeText " "
    Wend
    .MoveLeft Unit:=wdCharacter, Count:=1
    .TypeText sChords(ie)
    Next
    
    
    With Selection.ParagraphFormat
        .LeftIndent = InchesToPoints(0)
        .RightIndent = InchesToPoints(0)
        .SpaceBefore = 0
        .SpaceBeforeAuto = False
        .SpaceAfter = 0
        .SpaceAfterAuto = False
        .LineSpacingRule = wdLineSpaceMultiple
        .LineSpacing = LinesToPoints(1.15)
        .Alignment = wdAlignParagraphLeft
        .WidowControl = True
        .KeepWithNext = False
        .KeepTogether = False
        .PageBreakBefore = False
        .NoLineNumber = False
        .Hyphenation = True
        .FirstLineIndent = InchesToPoints(0)
        .OutlineLevel = wdOutlineLevelBodyText
        .CharacterUnitLeftIndent = 0
        .CharacterUnitRightIndent = 0
        .CharacterUnitFirstLineIndent = 0
        .LineUnitBefore = 0
        .LineUnitAfter = 0
        .MirrorIndents = False
        .TextboxTightWrap = wdTightNone
    End With
    
    
    
    

    
    
    
    
    
'    Dim lEndChord As Long
'    .endKey Unit:=wdLine
'    lEndChord = .End
'    .MoveDown Unit:=wdLine
'    Dim lEndText As Long
'    .endKey Unit:=wdLine
'    lEnd = Selection.End
'    .HomeKey Unit:=wdLine
    
    
'
'    Dim rngText As Range
'    Set rngText = Selection.Range
'    Dim lRightText As Long
'    lRightText = .Information(wdHorizontalPositionRelativeToPage)
'    Selection.MoveUp Unit:=wdLine
'    Dim lRightChord As Long
'    lRightChord = .Information(wdHorizontalPositionRelativeToPage)
'    If lRightChord = lRightText Or lRightChord < lRightText Then
'        .MoveRight Unit:=wdCharacter, Extend:=wdExtend
'    Else
'        .MoveLeft Unit:=wdChracter, Extend:=wdExtend
'    End If
'    If .Text <> " " And .Start <> lEndChord Then
'        Selection.MoveRight Unit:=wdWord, Count:=1
'    End If
'
'
'
'    .MoveRight Unit:=wdCharacter, Extend:=wdExtend
    
    
    
    Debug.Print .Information(wdHorizontalPositionRelativeToPage)
    End With

End Sub




Public Sub getChordText(ByRef getSomeChordText As String)
    Dim sChords() As String
    Dim sChordsText As String
    sChordsText = getLine
    Dim sChordsArray() As String

    sChordsArray = Split(sChordsText, " ")
    Dim iChord As Integer
    iChord = 0
    Dim schord As Variant
    For Each schord In sChordsArray
        If schord <> "" And schord <> "." And schord <> " " Then
            'sChordsForReals(iChord) = schord
            iChord = iChord + 1
        End If
    Next schord
    
    ReDim sChordsForReals(0 To iChord - 1) As String
    iChord = 0
    For Each schord In sChordsArray
        If schord <> "" And schord <> "." And schord <> " " Then
            sChordsForReals(iChord) = schord
            iChord = iChord + 1
        End If
    Next schord
    Dim isfirstone As Boolean
    isfirstone = True
    For Each schord In sChordsForReals
        If isfirstone Then
            getSomeChordText = schord
        Else
            getSomeChordText = getSomeChordText + "," + schord
        End If
        isfirstone = False
    Next schord
    
    Debug.Print getSomeChordText
'    Selection.MoveDown Unit:=wdLine
'    Selection.HomeKey Unit:=wdLine
    
    
    
End Sub

